import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
//导入全局样式表
import './assets/scss/global.scss'
// 导入字体图标
import './assets/fonts/iconfont.css'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
//导入nprogress 包对应的js和css
import Nprogress from "nprogress"
import "nprogress/nprogress.css"

Vue.use(VueQuillEditor)

//配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/';
// axios拦截器
axios.interceptors.request.use(config => {
  Nprogress.start()
  //为请求头对象，添加token验证的authorization字段
  config.headers.Authorization = window.sessionStorage.getItem("token")
  // console.log(config);
  return config
})
axios.interceptors.response.use(config=>{
  Nprogress.done()
  return config
})
Vue.prototype.axios = axios
Vue.component("tree-table", TreeTable)
Vue.filter("dateFormat", (originVal) => {
  const dt = new Date(originVal)
  const year = dt.getFullYear()
  const month = (dt.getMonth() + 1 + "").padStart(2, "0")
  const day = (dt.getDay() + "").padStart(2, "0")
  const hour = (dt.getHours() + "").padStart(2, "0")
  const minute = (dt.getMinutes() + "").padStart(2, "0")
  const second = (dt.getSeconds() + "").padStart(2, "0")

  return `${year}-${month}-${day} ${hour}:${minute}:${second}`
})


Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
